package com.yanqu.road.server.manger.player;

import com.yanqu.road.entity.player.UserBadge;
import com.yanqu.road.logic.bussiness.player.UserBadgeBussiness;
import com.yanqu.road.server.TempMgr;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class BadgeMgr extends TempMgr {

    private static Map<Long, List<UserBadge>> userBadgeMap = new ConcurrentHashMap<>();

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        userBadgeMap = UserBadgeBussiness.getAllUserBadgeMap();
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }


    public static List<UserBadge> getUserBadgeList(long userId) {
        return userBadgeMap.get(userId);
    }

    public static void updateUserBadge(long userId, List<UserBadge> userBadgeList) {
        synchronized (userBadgeMap) {
            userBadgeMap.put(userId, userBadgeList);
        }
    }
}
